import requests


class IhrmEmpAdminApi():
    #添加员工
    @classmethod
    def add_emp(cls,header,add_data):
        url = "http://ihrm-test.itheima.net/api/sys/user/"
        resp = requests.post(url=url, headers=header, json=add_data)
        return resp
    #查询员工
    @classmethod
    def query_emp(cls,emp_id,header):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id

        resp = requests.get(url=url, headers=header)
        return resp
    #修改员工
    @classmethod
    def modify_emp(cls,emp_id,header,modify_data):
        url_modify = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id
        resp = requests.put(url=url_modify, headers=header, json=modify_data)
        return resp
    #删除员工
    @classmethod
    def delete_emp(cls,emp_id,header):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id
        resp = requests.delete(url=url, headers=header)
        return resp
if __name__ == '__main__':
    header = {"Content-Type": "application/json", "Authorization": "Bearer 39ea70f7-b10b-4660-8690-69688da46178"}
    # add_data ={"username": "业务猪001", "mobile": "13978734722", "workNumber": "9527"}
    # resp = IhrmEmpAdminApi.add_emp(header,add_data)
    # print(resp.json())
    emp_id = '1530810519320068096'
    resp = IhrmEmpAdminApi.query_emp(emp_id,header)
    print(resp.json())
    modify_data ={"username": "齐天大圣"}
    resp = IhrmEmpAdminApi.modify_emp(emp_id,header,modify_data)
    print(resp.json())
    resp = IhrmEmpAdminApi.delete_emp(emp_id,header)
    print(resp.json())